package com.zxbit.flash.presenter;

import com.zxbit.flash.BuildConfig;
import com.zxbit.flash.base.BasePresenter;
import com.zxbit.flash.common.UserInfo;
import com.zxbit.flash.mvpview.HelpCenterMvpView;
import com.zxbit.flash.network.CustomConsumer;
import com.zxbit.flash.network.ParamsFactory;
import com.zxbit.flash.response.HelpCenterResponse;

import io.reactivex.functions.Consumer;

public class HelpCenterPresenter extends BasePresenter {
    private HelpCenterMvpView mvpView;

    public HelpCenterPresenter(HelpCenterMvpView mvpView) {
        this.mvpView = mvpView;
    }

    public void getData() {
        toSubScribe(req.getHelpCenter(BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(null)), new CustomConsumer<HelpCenterResponse>() {
            @Override
            public void call(HelpCenterResponse helpCenterResponse) {
                mvpView.onGetDataNext(helpCenterResponse);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                mvpView.onGetDataError(throwable);
            }
        });
    }
}
